<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

use think\facade\Route;


Route::group('admin', function () {
    //    更新浏览量缓存的路由，这个api默认只允许让服务器来调用
    Route::rule(
        'Common/updateCacheView', 'admin/Common/updateCacheView', 'get'
    );
    //    更新会员到期的站点的状态
    Route::rule(
        'Common/updateTenantStatus', 'admin/Common/updateTenantStatus', 'get'
    );
    Route::rule(
        'Login/index', 'admin/Login/index', 'post'
    );
    Route::rule(
        'User/register', 'admin/User/register', 'post'
    );
    Route::rule(
        'User/forgot', 'admin/User/forgot', 'post'
    );
    Route::rule(
        'ThirdLogin/getQQCode', 'admin/ThirdLogin/getQQCode', 'get'
    );
    Route::rule(
        'ThirdLogin/getWxCode', 'admin/ThirdLogin/getWxCode', 'get'
    );
    Route::rule(
        'ThirdLogin/wx', 'admin/ThirdLogin/wx', 'get'
    );
    Route::rule(
        'ThirdLogin/loginByQQ', 'admin/ThirdLogin/loginByQQ', 'get'
    );
    Route::rule(
        'ThirdLogin/loginByWx', 'admin/ThirdLogin/loginByWx', 'get'
    );
    Route::rule(
        'ThirdLogin/checkWxLogin', 'admin/ThirdLogin/checkWxLogin', 'get'
    );
    Route::rule(
        'ThirdLogin/getQr', 'admin/ThirdLogin/getQr', 'get'
    );
    Route::rule(
        'Index/upload', 'admin/Index/upload', 'post'
    )->middleware(['AdminAuth', 'AdminLog']);
    Route::rule(
        'Login/logout', 'admin/Login/logout', 'get'
    )->middleware(['AdminAuth', 'AdminLog']);
    Route::rule(
        'Login/getUserInfo', 'admin/Login/getUserInfo', 'get'
    )->middleware(['AdminAuth', 'AdminLog']);

    //大部分控制器的路由都以分组的形式写到这里
    Route::group('Menu', [
        'index' => [
            'admin/Menu/index',
            ['method' => 'get']
        ],
        'changeStatus' => [
            'admin/Menu/changeStatus',
            ['method' => 'get']
        ],
        'add' => [
            'admin/Menu/add',
            ['method' => 'post']
        ],
        'edit' => [
            'admin/Menu/edit',
            ['method' => 'post']
        ],
        'del' => [
            'admin/Menu/del',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);
    Route::group('User', [
        'index' => [
            'admin/User/index',
            ['method' => 'get']
        ],
        'getUsers' => [
            'admin/User/getUsers',
            ['method' => 'get']
        ],
        'changeStatus' => [
            'admin/User/changeStatus',
            ['method' => 'get']
        ],
        'add' => [
            'admin/User/add',
            ['method' => 'post']
        ],
        'own' => [
            'admin/User/own',
            ['method' => 'post']
        ],
        'edit' => [
            'admin/User/edit',
            ['method' => 'post']
        ],
        'del' => [
            'admin/User/del',
            ['method' => 'get']
        ],
    ])->middleware(['AdminAuth', 'AdminPermission', 'CheckUser', 'AdminLog']);
    Route::group('Auth', [
        'index' => [
            'admin/Auth/index',
            ['method' => 'get']
        ],
        'changeStatus' => [
            'admin/Auth/changeStatus',
            ['method' => 'get']
        ],
        'add' => [
            'admin/Auth/add',
            ['method' => 'post']
        ],
        'delMember' => [
            'admin/Auth/delMember',
            ['method' => 'get']
        ],
        'edit' => [
            'admin/Auth/edit',
            ['method' => 'post']
        ],
        'del' => [
            'admin/Auth/del',
            ['method' => 'get']
        ],
        'getGroups' => [
            'admin/Auth/getGroups',
            ['method' => 'get']
        ],
        'getRuleList' => [
            'admin/Auth/getRuleList',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);
    Route::group('App', [
        'index' => [
            'admin/App/index',
            ['method' => 'get']
        ],
        'refreshAppSecret' => [
            'admin/App/refreshAppSecret',
            ['method' => 'get']
        ],
        'changeStatus' => [
            'admin/App/changeStatus',
            ['method' => 'get']
        ],
        'add' => [
            'admin/App/add',
            ['method' => 'post']
        ],
        'getAppInfo' => [
            'admin/App/getAppInfo',
            ['method' => 'get']
        ],
        'edit' => [
            'admin/App/edit',
            ['method' => 'post']
        ],
        'del' => [
            'admin/App/del',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);
    Route::group('InterfaceList', [
        'index' => [
            'admin/InterfaceList/index',
            ['method' => 'get']
        ],
        'changeStatus' => [
            'admin/InterfaceList/changeStatus',
            ['method' => 'get']
        ],
        'add' => [
            'admin/InterfaceList/add',
            ['method' => 'post']
        ],
        'refresh' => [
            'admin/InterfaceList/refresh',
            ['method' => 'get']
        ],
        'edit' => [
            'admin/InterfaceList/edit',
            ['method' => 'post']
        ],
        'del' => [
            'admin/InterfaceList/del',
            ['method' => 'get']
        ],
        'getHash' => [
            'admin/InterfaceList/getHash',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);
    Route::group('Fields', [
        'index' => [
            'admin/Fields/index',
            ['method' => 'get']
        ],
        'request' => [
            'admin/Fields/request',
            ['method' => 'get']
        ],
        'add' => [
            'admin/Fields/add',
            ['method' => 'post']
        ],
        'response' => [
            'admin/Fields/response',
            ['method' => 'get']
        ],
        'edit' => [
            'admin/Fields/edit',
            ['method' => 'post']
        ],
        'del' => [
            'admin/Fields/del',
            ['method' => 'get']
        ],
        'upload' => [
            'admin/Fields/upload',
            ['method' => 'post']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);
    Route::group('InterfaceGroup', [
        'index' => [
            'admin/InterfaceGroup/index',
            ['method' => 'get']
        ],
        'getAll' => [
            'admin/InterfaceGroup/getAll',
            ['method' => 'get']
        ],
        'add' => [
            'admin/InterfaceGroup/add',
            ['method' => 'post']
        ],
        'changeStatus' => [
            'admin/InterfaceGroup/changeStatus',
            ['method' => 'get']
        ],
        'edit' => [
            'admin/InterfaceGroup/edit',
            ['method' => 'post']
        ],
        'del' => [
            'admin/InterfaceGroup/del',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);
    Route::group('AppGroup', [
        'index' => [
            'admin/AppGroup/index',
            ['method' => 'get']
        ],
        'getAll' => [
            'admin/AppGroup/getAll',
            ['method' => 'get']
        ],
        'add' => [
            'admin/AppGroup/add',
            ['method' => 'post']
        ],
        'changeStatus' => [
            'admin/AppGroup/changeStatus',
            ['method' => 'get']
        ],
        'edit' => [
            'admin/AppGroup/edit',
            ['method' => 'post']
        ],
        'del' => [
            'admin/AppGroup/del',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);
    Route::group('Log', [
        'index' => [
            'admin/Log/index',
            ['method' => 'get']
        ],
        'del' => [
            'admin/Log/del',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);
    Route::group('Sms', [
        'getSmsCode' => [
            'admin/Sms/getSmsCode',
            ['method' => 'get']
        ]
    ])->middleware(['CheckSms']);;

    Route::group('Oss', [
        'uploadFile' => [
            'admin/Oss/uploadFile',
            ['method' => 'post']
        ],
        'del' => [
            'admin/Oss/deleteFile',
            ['method' => 'get']
        ],
        'get' => [
            'admin/Oss/get',
            ['method' => 'get']
        ],
        'save' => [
            'admin/Oss/save',
            ['method' => 'post']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminLog']);;
    Route::group('Test', [
        'index' => [
            'admin/Test/index',
            ['method' => 'get']
        ]
    ]);
    Route::group('Notify', [
        'wxPayNotify' => [
            'admin/Notify/wxPayNotify',
            ['method' => 'post']
        ],
        'wxRefundNotify' => [
            'admin/Notify/wxRefundNotify',
            ['method' => 'post']
        ]
    ]);
    Route::group('Imgs', [
        'index' => [
            'admin/Imgs/index',
            ['method' => 'get']
        ],
        'getFolders' => [
            'admin/Imgs/getFolders',
            ['method' => 'get']
        ],
        'getImgs' => [
            'admin/Imgs/getImgs',
            ['method' => 'get']
        ],
        'delImg' => [
            'admin/Imgs/delImg',
            ['method' => 'get']
        ],
        'uploadImg' => [
            'admin/Imgs/uploadImg',
            ['method' => 'post']
        ],
        'addFolder' => [
            'admin/Imgs/addFolder',
            ['method' => 'get']
        ],
        'delFolder' => [
            'admin/Imgs/delFolder',
            ['method' => 'get']
        ],
        'renameFolder' => [
            'admin/Imgs/renameFolder',
            ['method' => 'get']
        ],
        'move' => [
            'admin/Imgs/move',
            ['method' => 'get']
        ],
        'delImgs' => [
            'admin/Imgs/delImgs',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);;
    Route::group('Site', [
        'get' => [
            'admin/Site/get',
            ['method' => 'get']
        ],
        'save' => [
            'admin/Site/save',
            ['method' => 'post']
        ],
        'adminSave' => [
            'admin/Site/adminSave',
            ['method' => 'post']
        ],
        'getSitesByAdmin' => [
            'admin/Site/getSitesByAdmin',
            ['method' => 'get']
        ],
        'getByAdmin' => [
            'admin/Site/getByAdmin',
            ['method' => 'get']
        ],
        'uploadCert' => [
            'admin/Site/uploadCert',
            ['method' => 'post']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('SiteView', [
        'getSiteView' => [
            'admin/SiteView/getSiteView',
            ['method' => 'get']
        ],
        'saveSiteView' => [
            'admin/SiteView/saveSiteView',
            ['method' => 'post']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Distribution', [
        'get' => [
            'admin/Distribution/get',
            ['method' => 'get']
        ],
        'save' => [
            'admin/Distribution/save',
            ['method' => 'post']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Stores', [
        'save' => [
            'admin/Stores/save',
            ['method' => 'post']
        ],
        'del' => [
            'admin/Stores/del',
            ['method' => 'get']
        ],
        'edit' => [
            'admin/Stores/edit',
            ['method' => 'post']
        ],
        'get' => [
            'admin/Stores/get',
            ['method' => 'get']
        ],
        'list' => [
            'admin/Stores/getList',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'CheckStores']);
    Route::group('Actives', [
        'save' => [
            'admin/Actives/save',
            ['method' => 'post']
        ],
        'del' => [
            'admin/Actives/del',
            ['method' => 'get']
        ],
        'get' => [
            'admin/Actives/get',
            ['method' => 'get']
        ],
        'list' => [
            'admin/Actives/getList',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission', 'AdminCheckActive']);
    Route::group('Category', [
        'save' => [
            'admin/Category/save',
            ['method' => 'post']
        ],
        'del' => [
            'admin/Category/del',
            ['method' => 'get']
        ],
        'get' => [
            'admin/Category/get',
            ['method' => 'get']
        ],
        'list' => [
            'admin/Category/getList',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Subject', [
        'save' => [
            'admin/Subject/save',
            ['method' => 'post']
        ],
        'bind' => [
            'admin/Subject/bind',
            ['method' => 'post']
        ],
        'unbind' => [
            'admin/Subject/unbind',
            ['method' => 'post']
        ],
        'del' => [
            'admin/Subject/del',
            ['method' => 'get']
        ],
        'get' => [
            'admin/Subject/get',
            ['method' => 'get']
        ],
        'list' => [
            'admin/Subject/getList',
            ['method' => 'get']
        ],
        'boundList' => [
            'admin/Subject/boundList',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Vip', [
        'save' => [
            'admin/Vip/save',
            ['method' => 'post']
        ],
        'get' => [
            'admin/Vip/get',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('StoreTag', [
        'save' => [
            'admin/StoreTag/save',
            ['method' => 'post']
        ],
        'del' => [
            'admin/StoreTag/del',
            ['method' => 'get']
        ],
        'get' => [
            'admin/StoreTag/get',
            ['method' => 'get']
        ],
        'list' => [
            'admin/StoreTag/getList',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('StoreUser', [
        'save' => [
            'admin/StoreUser/save',
            ['method' => 'post']
        ],
        'del' => [
            'admin/StoreUser/del',
            ['method' => 'get']
        ],
        'getByNickName' => [
            'admin/StoreUser/getByNickName',
            ['method' => 'get']
        ],
        'list' => [
            'admin/StoreUser/getList',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Order', [
        'del' => [
            'admin/Order/del',
            ['method' => 'get']
        ],
        'getList' => [
            'admin/Order/getList',
            ['method' => 'get']
        ],
        'getDetail' => [
            'admin/Order/getDetail',
            ['method' => 'get']
        ],
        'refund' => [
            'admin/Order/refund',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Comment', [
        'del' => [
            'admin/Comment/del',
            ['method' => 'get']
        ],
        'getList' => [
            'admin/Comment/getList',
            ['method' => 'get']
        ],
        'getDetail' => [
            'admin/Comment/getDetail',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Complain', [
        'del' => [
            'admin/Complain/del',
            ['method' => 'get']
        ],
        'getList' => [
            'admin/Complain/getList',
            ['method' => 'get']
        ],
        'getDetail' => [
            'admin/Complain/getDetail',
            ['method' => 'get']
        ],
        'changeStatus' => [
            'admin/Complain/changeStatus',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);

    Route::group('Suggest', [
        'del' => [
            'admin/Suggest/del',
            ['method' => 'get']
        ],
        'getList' => [
            'admin/Suggest/getList',
            ['method' => 'get']
        ],
        'getDetail' => [
            'admin/Suggest/getDetail',
            ['method' => 'get']
        ],
        'changeStatus' => [
            'admin/Suggest/changeStatus',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Bill', [
        'getBill' => [
            'admin/Bill/getBill',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Tenant', [
        'editCustomerService' => [
            'admin/Tenant/editCustomerService',
            ['method' => 'post']
        ],
        'getCustomerService' => [
            'admin/Tenant/getCustomerService',
            ['method' => 'get']
        ], 'editTabbar' => [
            'admin/Tenant/editTabbar',
            ['method' => 'post']
        ],
        'getTabbar' => [
            'admin/Tenant/getTabbar',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('Withdrawals', [
        'getList' => [
            'admin/Withdrawals/getList',
            ['method' => 'get']
        ],
        'finish' => [
            'admin/Withdrawals/finish',
            ['method' => 'get']
        ],
        'close' => [
            'admin/Withdrawals/close',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
//    统计
    Route::group('Statistics', [
        'getActiveData' => [
            'admin/Statistics/getActiveData',
            ['method' => 'get']
        ],
        'getNoticeData' => [
            'admin/Statistics/getNoticeData',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    Route::group('AppUser', [
        'edit' => [
            'admin/AppUser/edit',
            ['method' => 'post']
        ],
        'changeStatus' => [
            'admin/AppUser/changeStatus',
            ['method' => 'get']
        ],
        'getDetail' => [
            'admin/AppUser/getDetail',
            ['method' => 'get']
        ],
        'list' => [
            'admin/AppUser/getList',
            ['method' => 'get']
        ]
    ])->middleware(['AdminAuth', 'AdminPermission']);
    //MISS路由定义
    Route::miss('admin/Miss/index');
})->middleware('AdminResponse');

